package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsTitle string  `gorm:"type:varchar(30);not null;comment:商品标题"`
	GoodsNum   int     `gorm:"type:int(11);not null;comment:数量"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);not null;comment:价格"`
	GoodsCover string  `gorm:"type:varchar(20);not null;comment:封面"`
	GoodsStock int     `gorm:"type:int(11);not null;comment:库存"`
	Status     string  `gorm:"type:tinyint(1);default:;not null;comment:状态"`
}

func (g *Goods) Create() error {
	return Db.Create(*g).Error
}
func (g *Goods) CartInfo(GoodsId int) error {
	return Db.Where("id = ?", GoodsId).Limit(1).Find(&g).Error
}
